import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    moduleId: sessionStorage.getItem('moduleId') ? sessionStorage.getItem('moduleId') : '',
    AxiosNull: 0,
    layoutData: sessionStorage.getItem('layoutData') ? sessionStorage.getItem('layoutData') : '',
    jurisdiction: sessionStorage.getItem('jurisdiction') ? sessionStorage.getItem('jurisdiction') : ''
  },

  mutations: {
    saveModuleId (state, user) { // 模块ID
      sessionStorage.setItem('moduleId', user.moduleId) // 数据保存sessionStorage里
      state.moduleId = user.moduleId // 修改state中的状态
    },
    layoutData (state, user) { // 菜单
      sessionStorage.setItem('layoutData', user)
      state.layoutData = user
    },
    jurisdiction (state, user) { // 菜单
      sessionStorage.setItem('jurisdiction', user)
      state.jurisdiction = user
    },
    AxiosJia (state) {
      state.AxiosNull++
    },
    AxiosJian (state) {
      state.AxiosNull--
    },
    AxiosAbnormal (state) {
      state.AxiosNull = 0
    }
  },
  actions: {},
  modules: {}
});
